package folder.main.exp2.algorithms;

import java.util.Comparator;
import java.util.List;

import folder.model.link.Link;
import folder.model.network.Network;
import folder.model.node.Node;
import folder.model.virtual.VirtualNetwork;

public class Pruebas extends Algorithm2
{	
	// Algorithm
	
	public static Pruebas pruebas( Network network, double delayThreshold, List< VirtualNetwork > virtualNetworks )
	{
		return new Pruebas( network, delayThreshold, virtualNetworks );
	}
	
	public Pruebas( Network network, double delayThreshold, List< VirtualNetwork > virtualNetworks )
	{
		super( network, delayThreshold, virtualNetworks );
		
		this.comparator = new ComparatorAbwBalanced();
		
		//for( VirtualNetwork virtualNetwork: virtualNetworks )
		//	network.getNetworkAllocation().allocateVirtualNetwork( virtualNetwork );
		
		this.checkAlgorithm = this.run();
	}
	
	// Comparator
	
    private class ComparatorAbwBalanced implements Comparator< Node >
    {   
    	@Override
    	public int compare( Node nodeX, Node nodeY )
    	{
    		Double abwNodeX = nodeX.getDelayToNodeTargetMean() / nodeX.getNumberPaths();
    		Double abwNodeY = nodeY.getDelayToNodeTargetMean() / nodeY.getNumberPaths();
    		
    		return abwNodeX.compareTo( abwNodeY );
    	}
    }

}
